﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace OpenCompiler.Scanning.Tests.Specs_for_scanner
{
	[TestClass]
	public class When_scanning_for_compiler_directives
	{
		[TestMethod]
		public void Simple_regions_are_recognized()
		{
			const string sourceCode = "#region\n#endregion";
			var tokens = TokenTestHelper.TokenizeWithoutEOF(sourceCode);
			Assert.AreEqual(3,tokens.Count);
			Assert.AreEqual(CompilerDirectives.REGION,tokens[0].ActualToken);
			Assert.AreEqual(CompilerDirectives.ENDREGION,tokens[2].ActualToken);
		}

		[TestMethod]
		public void Simple_ifs_are_recognized()
		{
			const string sourceCode = "#if\n#endif";
			var tokens = TokenTestHelper.TokenizeWithoutEOF(sourceCode);
			Assert.AreEqual(3, tokens.Count);
			Assert.AreEqual(CompilerDirectives.IF, tokens[0].ActualToken);
			Assert.AreEqual(CompilerDirectives.ENDIF, tokens[2].ActualToken);
		}

		[TestMethod]
		public void Ifs_with_arguments_are_recognized()
		{
			const string sourceCode = "#if(true)\n#endif";
			var tokens = TokenTestHelper.TokenizeWithoutEOF(sourceCode);
			Assert.AreEqual(6, tokens.Count);
			Assert.AreEqual(CompilerDirectives.IF, tokens[0].ActualToken);
			Assert.AreEqual(CompilerDirectives.ENDIF, tokens[5].ActualToken);
			
		}

		[TestMethod]
		public void Pragma_is_recognized()
		{
			const string sourceCode = "#pragma(SomeArgument)";
			var tokens = TokenTestHelper.TokenizeWithoutEOF(sourceCode);
			Assert.AreEqual(4,tokens.Count);
			Assert.AreEqual(CompilerDirectives.PRAGMA,tokens[0].ActualToken);
		}
	}
}